package com.wb.proxy.static_;

/**
 * @author 魏彪
 */
public class TargetProxy implements TargetInterface {

    // 持有目标对象的引用
    private TargetInterface targetInterface;

    public TargetProxy(TargetInterface targetInterface) {
        this.targetInterface = targetInterface;
    }

    @Override
    public void sayHello(String name) {
        System.out.println("......方法执行之前......");
        // 执行目标方法
        targetInterface.sayHello(name);
        System.out.println("......方法执行之后......");
    }

    @Override
    public void sayThanks(String name) {
        System.out.println("......方法执行之前......");
        // 执行目标方法
        targetInterface.sayThanks(name);
        System.out.println("......方法执行之后......");
    }
}
